<!-- 巷道管理 - 综合表单页面 -->
<template>
  <div class="page-container">
    <page_breadcrumb :getKeyMethod="init_table_model" @change="change_table_model" pageOption />
    <ex_super_table_page v-bind="option" ref="SuperTablePage">
    </ex_super_table_page>
    <ex_super_dialog_form ref="formDialog" v-bind="dialog" @afterSubmitSuccess="$refs['SuperTablePage'].reload()">
    </ex_super_dialog_form>
  </div>
</template>
<script>
import superTablePageFunction from '@/mixin/super-table-page-function';
import page_table_model_manage from '@/mixin/page_table_model_manage';

export default {
  title: 'title_Tunnel_manage',
  mixins: [superTablePageFunction, page_table_model_manage],
  components: {},
  data() {
    return {

      option: {
        search: {
          model: [
            {
              label: "label_warehouse_area", key: "areaId", type: 'base_area_select',

            },

            { label: "label_tunnel_code", key: "alleyCode", type: 'input', },
            {
              label: "label_type", key: "alleyType", type: 'select', enum: 'BaseAlleyTypeEnum',
            },
            {
              label: "label_start_time",
              key: "createDateStart",
              fold: true,
              type: 'date-picker',
              attrs: { type: "datetime" },
            },
            {
              label: "label_end_time",
              key: "createDateEnd",
              fold: true,
              type: 'date-picker',
              attrs: { type: "datetime" },
            },
          ],
        },
        action: [
          {
            label: 'label_add_Tunnel', auth: 'wms_alley_setting_edit', attrs: { icon: "el-icon-plus" }, click: () => {
              this['$refs']['formDialog'].showNew({
                title: this.$tt('label_add_Tunnel'),
                data: {},
                onlySetData: true
              })
            }
          },
        ],

        table: {
          url: "/wms-api/base/WmsBaseAlleyRpc/selectPage.json",
          attrs: {},
          model: this.init_table_model(),
        },
      },
      dialog: {
        customClass: 'dialog_auto',
        submitUrl: '/wms-api/base/WmsBaseAlleyRpc/saveUpdate.json',
        detailUrl: '/wms-api/base/WmsBaseAlleyRpc/detail.json',
        form: {
          itemClass: "form_item_default", inputClass: "form_input_default",
          model: [
            { key: 'code', label: 'label_tunnel_code', if: (data) => data.code, disabled: true },
            { key: 'type', label: 'label_tunnel_type', type: 'select', enum: 'BaseAlleyTypeEnum' },
            {
              label: "label_belong_warehouse_area", key: "areaId", type: 'base_area_select',  disabled: data => data.id !== undefined ,
            },

            { key: 'startPointX', label: 'label_start_point_X_axis_coordinate', },
            { key: 'startPointY', label: 'label_start_point_Y_axis_coordinate', },
            { key: 'endPointX', label: 'label_end_point_X_axis_coordinate', },
            { key: 'endPointY', label: 'label_end_point_Y_axis_coordinate', },
          ],
          rules: {
            'type': { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
            'areaId': { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
            'startPointX': { required: true, pattern: /^[0-9]+(\.[0-9]{1,2})?$/, message: this.$tt('tip_only_positive_to_two_decimal'), trigger: 'blur' },
            'startPointY': { required: true, pattern: /^[0-9]+(\.[0-9]{1,2})?$/, message: this.$tt('tip_only_positive_to_two_decimal'), trigger: 'blur' },
            'endPointX': { required: true, pattern: /^[0-9]+(\.[0-9]{1,2})?$/, message: this.$tt('tip_only_positive_to_two_decimal'), trigger: 'blur' },
            'endPointY': { required: true, pattern: /^[0-9]+(\.[0-9]{1,2})?$/, message: this.$tt('tip_only_positive_to_two_decimal'), trigger: 'blur' },
          },
        }
      },
    };
  },
  methods: {
    option_table_model() {
      return [
        { key: 'code', label: 'label_tunnel_code', },
        { key: 'type', label: 'label_tunnel_type', type: 'select', enum: 'BaseAlleyTypeEnum' },
        { key: 'warehouseCode', label: 'label_warehouse_code', },
        { key: 'areaCode', label: 'label_warehouse_area_code', },
        { key: 'gmtCreate', label: 'label_create_time', 'min-width': 120, 'show-overflow-tooltip': true, formatter: (r, c, v, i) => this.$dateFormat(v) },
        {
          type: 'operate', width: 160, operate: [
            {
              label: 'label_edit', auth: 'wms_alley_setting_edit', click: (row) => {
                this.dialogTitle = this.$tt('label_edit_Tunnel')
                this['$refs']['formDialog'].show({ "id": row["id"] },)
              }
            },
            {
              label: 'label_delete', auth: 'wms_alley_setting_delete', type: "confirm-button", url: '/wms-api/base/WmsBaseAlleyRpc/remove.json', message: '确定要删除该记录吗？',
              buttonClass: "button_text_danger", confirmButtonType: 'danger',
              params: (row) => { return { "id": row["id"] } }, done: ['reload', 'tip']
            },
          ],
        }
      ]
    },
  }
};

</script>
<style></style>
